diff options
Diffstat (limited to 'pages/api/notes/[id].js')
-rw-r--r-- | pages/api/notes/[id].js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pages/api/notes/[id].js b/pages/api/notes/[id].js index 58e458f..12f0ba4 100644 --- a/pages/api/notes/[id].js +++ b/pages/api/notes/[id].js @@ -4,7 +4,7 @@ import NoteList from 'models/NoteList' import Note from 'models/Note' export default withSession(async (req, res) => { - const {id: _id} = req.query + const { id: _id } = req.query await dbConnect() switch (req.method) { @@ -12,7 +12,7 @@ export default withSession(async (req, res) => { try { const user = req.session.get('user') - if (!user || !user?.isVerified || !_id ) { + if (!user || !user?.isVerified || !_id) { throw new Error('Something went wrong') } @@ -25,7 +25,7 @@ export default withSession(async (req, res) => { res.status(200).json(note) } catch (error) { console.log(error) - res.status(400).json({error: true}) + res.status(400).json({ error: true }) } break case 'DELETE': @@ -37,10 +37,10 @@ export default withSession(async (req, res) => { } const noteId = await NoteList.getNoteId(user.noteList, _id) - if ( !noteId) throw new Error('Something went wrong') + if (!noteId) throw new Error('Something went wrong') await Note.findByIdAndDelete(noteId) - const {notes} = await NoteList.removeNote(user.noteList, _id) + const { notes } = await NoteList.removeNote(user.noteList, _id) res.status(200).json(notes) } catch (error) { @@ -51,14 +51,14 @@ export default withSession(async (req, res) => { case 'PUT': try { const user = req.session.get('user') - const {title, noteId, content} = req.body + const { title, noteId, content } = req.body if (!user || !user?.isVerified || !_id || !content) { throw new Error('Something went wrong') } await Note.updateNote(noteId, content) - const {notes} = await NoteList.updateList(user.noteList, noteId, title) + const { notes } = await NoteList.updateList(user.noteList, noteId, title) res.status(200).json(notes) } catch (error) { |